package com.runa.protocol.dto;

import com.runa.protocol.enums.S7Enum;
import com.runa.protocol.enums.S7Error;

import java.util.ArrayList;
import java.util.List;

public class S7ResponseData implements IResponseData<List<S7DataItem>> {

    private COTPSectionData cotpSectionData;

    private S7Enum.PDUType pduType;

    private short pduRef;

    private int paramLen;

    private int dataLen;

    private S7Error.S7ErrorClass errorClass;

    private S7Error.S7ErrorCode errorCode;

    private S7Enum.FunCode funCode;

    private List<S7DataItem> dataItems = new ArrayList<>();

    //以下是初始化包才有的字段
    private int maxCaller;

    private int maxCallee;

    private int pduLength;

    public S7ResponseData(COTPSectionData cotpSectionData) {
        this.cotpSectionData = cotpSectionData;
    }

    public COTPSectionData getCotpSectionData() {
        return cotpSectionData;
    }

    public S7Enum.PDUType getPduType() {
        return pduType;
    }

    public void setPduType(S7Enum.PDUType pduType) {
        this.pduType = pduType;
    }

    public void setPduRef(short pduRef) {
        this.pduRef = pduRef;
    }

    public int getParamLen() {
        return paramLen;
    }

    public void setParamLen(int paramLen) {
        this.paramLen = paramLen;
    }

    public int getDataLen() {
        return dataLen;
    }

    public void setDataLen(int dataLen) {
        this.dataLen = dataLen;
    }

    public S7Error.S7ErrorClass getErrorClass() {
        return errorClass;
    }

    public void setErrorClass(S7Error.S7ErrorClass errorClass) {
        this.errorClass = errorClass;
    }

    public S7Error.S7ErrorCode getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(S7Error.S7ErrorCode errorCode) {
        this.errorCode = errorCode;
    }

    public S7Enum.FunCode getFunCode() {
        return funCode;
    }

    public void setFunCode(S7Enum.FunCode funCode) {
        this.funCode = funCode;
    }

    public int getMaxCaller() {
        return maxCaller;
    }

    public void setMaxCaller(int maxCaller) {
        this.maxCaller = maxCaller;
    }

    public int getMaxCallee() {
        return maxCallee;
    }

    public void setMaxCallee(int maxCallee) {
        this.maxCallee = maxCallee;
    }

    public int getPduLength() {
        return pduLength;
    }

    public void setPduLength(int pduLength) {
        this.pduLength = pduLength;
    }

    @Override
    public List<S7DataItem> getData() {
        return dataItems;
    }

    public void addItem(S7DataItem item) {
        this.dataItems.add(item);
    }

    @Override
    public short getTransSign() {
        return pduRef;
    }
}
